﻿using System;
using System.Windows.Data;
using BizControl.Library.BusinessObjects.Marks;
using BizControl.Library.Helpers;
using System.Windows;
using System.Text;

namespace BizControl.Presentation.ActivityEditModule.Converters
{
  public class MarkStateToStringConverter : IValueConverter
  {
    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      StringBuilder sb = new StringBuilder();
      var state = (MarkState)value;
      if (state.HasFlag(MarkState.Completed)) sb.Append(MarkState.Completed.GetLocalizedDescription());
      if (state.HasFlag(MarkState.NotCompleted)) sb.Append(MarkState.NotCompleted.GetLocalizedDescription());
      if (state.HasFlag(MarkState.Overdue))
      {
        sb.Append(Environment.NewLine);
        sb.Append(MarkState.Overdue.GetLocalizedDescription());
      }
      return sb.ToString();
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      return null;
    }

    #endregion
  }
}